/**
 * Created by lixinkun on 2017/7/9.
 */
'use strict';
import * as types from '../actions/actionTypes';

const initState = {
    loading: false,
    dataSource: [],
    error: false,
}

/**
 * 获取地点的state
 * @param state
 * @param action
 * @returns {*}
 */
export default function areaDataState(state = initState, action) {
    switch (action.type) {
        case types.FETCH_AREA_DATA_REQUEST:
            return Object.assign({}, state, {
                ...state,
                loading: true,
                dataSource: [],
                error: false,
            });
        case types.FETCH_AREA_DATA_SUCCESS:
            return Object.assign({}, state, {
                ...state,
                loading: false,
                dataSource: action.dataSource,
            });
        case types.FETCH_AREA_DATA_FAILURE:
            return Object.assign({} ,state, {
                ...state,
                loading: false,
                dataSource: [],
                error: true,
            });
        default:
            return state;
    }

}